import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { PassportModule } from '@nestjs/passport';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ConfigService } from '@nestjs/config';
import { User } from '../users/entities/user.entity';
import { AuthController } from './controllers/auth.controller';
import { WalletAuthService } from './services/wallet-auth.service';
import { JwtStrategy } from './strategies/jwt.strategy';
import { AppI18nModule } from '../i18n/i18n.module';

@Module({
    imports: [
        TypeOrmModule.forFeature([User]),
        PassportModule.register({ defaultStrategy: 'jwt' }),
        JwtModule.registerAsync({
            useFactory: (configService: ConfigService) => ({
                secret: configService.get('jwt.secret'),
                signOptions: {
                    expiresIn: configService.get('jwt.expiresIn'),
                },
            }),
            inject: [ConfigService],
        }),
        AppI18nModule,
    ],
    controllers: [AuthController],
    providers: [WalletAuthService, JwtStrategy],
    exports: [WalletAuthService, JwtStrategy],
})
export class AuthModule { }
